package com.hmall.pay;

import com.hmall.common.config.DefaultFeignConfiguration;
import org.apache.http.HttpHost;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;

@SpringBootApplication
@EnableFeignClients(basePackages = "com.hmall.common.client",defaultConfiguration = DefaultFeignConfiguration.class)
public class SearchAppcation {
    public static void main(String[] args) {
        SpringApplication.run(SearchAppcation.class,args);
    }
    @Bean
    public RestHighLevelClient client(){
        return  new RestHighLevelClient(RestClient.builder(
                HttpHost.create("http://192.168.209.130:9200")
        ));
    }

    @Bean
    @LoadBalanced // 在从Eureka中获取服务提供者地址时,如果有多个则采用负载均衡
    public RestTemplate createRestTemplate(){
        return new RestTemplate();
    }
}
